package cn.sxt.yxl.head.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.sxt.yxl.common.util.ConstatFinalUtil;
import cn.sxt.yxl.question.pojo.Column;
import cn.sxt.yxl.question.pojo.ColumnEnum;
import cn.sxt.yxl.question.service.IQuestionService;

@Controller
public class IndexController {
	
	@Resource
	private IQuestionService questionService;
	
	@RequestMapping("/main")
	public String main(HttpServletRequest req){
		ConstatFinalUtil.LOGGER.info("----main-----");
		return "/head/main";
	}
	
	@RequestMapping("/{url}")
	public String itemList(HttpServletRequest req , @PathVariable String url){
		ConstatFinalUtil.LOGGER.info("----itemList-----"+url);
		
		return "/head/itemList";
	}
	
	@RequestMapping("/header")
	public String header(HttpServletRequest req , String id){
		ConstatFinalUtil.LOGGER.info("----header-----"+ id);
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("status", ColumnEnum.STATUS_ENABLE.getStatus());
		List<Column> columnList = questionService.findColumnListService(null, map);
		req.setAttribute("columnList", columnList);
		return "/head/head";
	}
	
}
